package cn.xjt.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * 内容：
 *
 * @author
 * @date 2020/9/26-16:14
 */

@Controller
@RequestMapping("/user")
public class loginController {

	@RequestMapping("/l")
	public String login(HttpSession session, String username, String password, Model model)
	{
//		把用户名保存session
		session.setAttribute("userLoginInfo", username);

		model.addAttribute("user", username);

		return "main";
	}

	@RequestMapping("/gologin")
	public String dologin()
	{
		return "login";
	}

	@RequestMapping("/main")
	public String main()
	{
		return "main";
	}

	@RequestMapping("/goout")
	public String goout(HttpSession session)
	{
		session.removeAttribute("userLoginInfo");

		return "main";
	}
}
